package nsq

import (
	sqlc "bp/db/sqlc"
	"context"
)

// GetPromotionPtr 获取带锁的nsq_sub
func (s *NsqEntityServiceImp) GetNsqSubPtrWithLock(ctx context.Context, q *sqlc.Queries, nsqSubID int64) (nsqSubPtr *sqlc.NsqSub, err error) {
	nsqSub, err := q.GetNsqSubToLock(ctx, nsqSubID)
	if err != nil {
		return
	}

	nsqSubPtr = &nsqSub
	return
}

// ListNsqSubPtrsWithLock 列出带锁的nsq_sub
func (s *NsqEntityServiceImp) ListNsqSubPtrsWithLock(ctx context.Context, q *sqlc.Queries, limit int32) (nsqSubPtrs []*sqlc.NsqSub, err error) {
	// slog := util.NewContextLogger(ctx, s.slog)
	rows, err := q.ListNsqSubsNotSuccessToLock(ctx, limit)
	if err != nil {
		return
	}
	// slog.Infof("1 ListNsqSubPtrsWithLock ok")
	nsqSubPtrs = s.MapNsqSubEntityToPtr(rows)
	return
}
